package com.qianyu.project.mapper.provider.gs;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.entity.TenderProjectInfo;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

import java.util.Map;

/**
 * @author gs
 * @date create in 2021/1/31 10:20
 */
public class TenderProjectInfoMapperProvider {

    public String selectPageList(IPage page, Map<String, String> params) {
        return new SQL(){
            {
                SELECT("tpi.*,pt.type_name");
                FROM("tender_project_info tpi,project_type pt");
                WHERE("tpi.project_type=pt.type_id");
                if(!ObjectUtils.isEmpty(params.get("projectName"))){
                    WHERE("tpi.project_name like '%${params.projectName}%'");
                }
                if(!ObjectUtils.isEmpty(params.get("projectType"))){
                    WHERE("tpi.project_type = #{params.projectType}");
                }
                if(!ObjectUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("tpi.approve_status = #{params.approveStatus}");
                }
            }
        }.toString();
    }
}
